package com.telenav;

public class Complex {

	public double real;
	public double image;

	public Complex() {
		real = 0;
		image = 0;
	}

	public Complex(double real, double image) {
		this.real = real;
		this.image = image;
	}

	public static Complex add(Complex c1, Complex c2) {
		Complex c = new Complex();
		c.real = c1.real + c2.real;
		c.image = c1.image + c2.image;
		return c;
	}

	public static Complex sub(Complex c1, Complex c2) {
		Complex c = new Complex();
		c.real = c1.real - c2.real;
		c.image = c1.image - c2.image;
		return c;

	}

	public static Complex mul(Complex c1, Complex c2) {
		Complex c = new Complex();
		c.real = c1.real * c2.real - c1.image * c2.image;
		c.image = c1.real * c2.image + c1.image * c2.real;
		return c;

	}

	public static Complex mul(Complex c1, double d) {
		Complex c = new Complex();
		c.real = c1.real * d;
		c.image = c1.image * d;
		return c;

	}

	public static Complex copy(Complex c1) {
		Complex c = new Complex();
		c.real = c1.real;
		c.image = c1.image;
		return c;
	}

	public String toString() {
		return real + "," + image;
	}
}
